<%@page contentType="text/html" language="java" import="com.compuvest.web.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@ taglib uri="/WEB-INF/tld/bottom.tld" prefix="bottom" %>
<%@ taglib uri="/WEB-INF/tld/head.tld" prefix="head" %>

<jsp:useBean id="sb" class="MySQL" scope="application"/>
<jsp:useBean id="advertArray" class="AdvertArray" scope="application"/>
<jsp:useBean id="basket" class="Basket" scope="session"/>
<%
    java.text.DecimalFormat priceForm = new java.text.DecimalFormat("$#,##0.00");

    int categoryID = advertArray.getInt(request.getParameter("cid"), 0);
    int subcatID = advertArray.getInt(request.getParameter("sid"), 0);
    int itemID = advertArray.getInt(request.getParameter("iid"), 0);

    String name = advertArray.getString(request.getParameter("Name"), "");
    String phone = advertArray.getString(request.getParameter("Phone"), "");
    String email = advertArray.getString(request.getParameter("Email"), "");
    String notation = advertArray.getString(request.getParameter("Notation"), "3");
    boolean isSendEmail = false;

    String mode = request.getParameter("mode");
    if(mode != null && email.length() != 0) {
        sb.setDropPrice(itemID, name, phone, email, notation);

        isSendEmail = true;
    }

    Item item = sb.getItemForBasket(itemID);
%>
<html>
<%@include file="/incl/head.html" %>

<body>

<table style='height:100%;'>

<tr height=100>
 <td colspan=3>

<head:show />

 </td>
</tr>

<tr valign=top align=center>
 <td style="width:160px;">&nbsp;</td>

 <td>

<div class=cstitle>Price Drop Alerts</div><br/>
<%
    if(isSendEmail) {
%>
<div style="display:block;position:relative;width:80%;background-color:white;">
<fieldset>
 <div class=pr style="padding:5px 20px">Dear Customer! Thank you for submitting your price-drop alert. If the price drops within
 the specified time-frame you will be notified by email (or phone). Please feel free to contact us if any questions.
 </div>
<br/>
<a class=btlgr href='<%= advertArray.getString((String)session.getAttribute("backItemsPage"), application.getInitParameter("http")) %>'>Continue Shopping</a>
<br/>

</fieldset></div>
<%
    }
    else {
%>
<div style="display:block;position:relativel;width:80%;background-color:white;">
<fieldset>

 <div class=pr style="padding:5px 20px">Dear CompuVest Customer! Welcome to Compuvest Price Drop Alerts, where you can
  sign up to receive alerts for price changes on your favorite products, direct to your email.<br/>
  Subscribe for Instant Email Alerts. Complete the form and click the Submit
  button to set an Alert.
 </div>

 <form action="<%= application.getInitParameter("http") + "DropPrice.jsp" %>" method='POST' onSubmit='return isFormReadyFog(this);' enctype="application/x-www-form-urlencoded">
 <input type=hidden name='cid' value="<%= categoryID %>"/>
 <input type=hidden name='sid' value="<%= subcatID %>"/>
 <input type=hidden name='iid' value="<%= itemID %>"/>

 <table width='90%' style="font-size:10pt;">
 <colgroup>
  <col width='30%'>
  <col width='70%'>
 </colgroup>
  <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
  <tr><td class=hdh>Product Code : </td><td><%= item.getAccwareCode() %></td></tr>
  <tr><td class=hdh>Product Name : </td><td><%= item.getItemName() %></td></tr>
  <tr><td class=hdh>Price : </td><td><%= priceForm.format(item.getPrice()) %></td></tr>
  <tr><td class=hdh>Notify me if : </td><td style='color:green;'>Price changes</td></tr>
  <tr><td class=hdh>Name : </td><td><input type=text size=40 maxLength=40 name='Name' value='<%= name %>'/></td></tr>
  <tr>
   <td class=hdh>Email address : </td>
   <td><input type=text size=40 maxLength=128 name='Email'/></td>
  </tr>
  <tr>
   <td class=hdh>Phone:</td>
   <td><input type=text size=40 maxLength=40 name='Phone' value='<%= phone %>'/></td>
  </tr>
  <tr><td>&nbsp;</td><td>If you wish to be notified by phone, please enter you phone number.</td></tr>
  <tr><td colspan=2>&nbsp;</td></tr>
  <tr><td colspan=2 class=hdh>Email me for&nbsp;&nbsp;&nbsp;
    <select name='Notation' size=1>
    <option value='7'/>7 days
    <option value='14'/>14 days
    <option value='30'/>1 month
    <option value='60'/>2 months
    <option value='90' selected />3 months
    <option value='120'/>6 months
   </select>
   &nbsp;&nbsp;whenever the price for this item goes down.<br/>
   </td>
  </tr>
  <tr><td colspan=2>&nbsp;</td></tr>
  <tr align=center><td colspan=2><input type=submit value='Submit' name='mode'/></td></tr>
 </table>
 </form>

</fieldset></div>
<%
    }
%>

 </td>

 <td style="width:160px;">&nbsp;</td>
</tr>

<tr height=35>
 <td colspan=3>

<bottom:show />

 </td>
</tr>

</table>

</body>
<%@ include file="./incl/tracking.incl" %>
</html>
